<#include "header.htm"/>
<#import "../macros/pagination.ftl" as pagination>
<#import "../macros/presentation.ftl" as presentation/>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/jquery.js?${startupTime}"></script>
<script type="text/javascript">
var __currentTopicID=0;
function getUrl(topic,id){
   self.location="${JForumContext.encodeURL("/posts/list/_topicid_")}".replace("_topicid_",topic)+(id!=undefined?"#"+id:"");
}
function getUserHome(userid){
   self.location="${JForumContext.encodeURL("/user/edit/_userid_")}".replace("_userid_",userid);
}
function getMore(o,id,reload){
    var displayid=document.getElementById("mA_"+id);
    if(displayid.style.display!='none'&&reload==undefined){
        o.src="${contextPath}/templates/${templateName}/images/icon_close.gif";
        displayid.style.display='none';
        return;
    }
	if(reload==undefined)
        o.src="${contextPath}/templates/${templateName}/images/icon_open.gif";
    displayid.style.display='';
    if(displayid.innerHTML!=""&&reload==undefined){
        return;
    }
    displayid.innerHTML="<img src=${contextPath}/templates/${templateName}/images/icon_loadding.gif>";
	__currentTopicID=id;
    getPostsByTopicId(id,0);
};
var getPostsByTopicId = function(id, start) {
    $.ajax({
        type:"POST",
        url: "${contextPath}/jforum.${extension}?module=ajax&action=getPostsByTopicId",
        data:{
            topicId:id,
            start:start
        },
        dataType:"script",
        global:false
    });
}
function callbackAm(data) {
  var datalog = "<ol class=olstyle>";
  var topicId=__currentTopicID;
  for (var d=1;d<data.length;d++) {
    topicId=data[d].topicId;
    datalog += "<li><a href=javascript:getUrl("+data[d].topicId+","+data[d].id+");>" + data[d].text.substring(0,50)+"</a> -- [<a href=javascript:getUserHome('"+data[d].userId+"')>"+data[d].postUsername+"</a>]"+ "</li>";
  }
displayid=document.getElementById("mA_"+topicId);
displayid.innerHTML=datalog+"</ol><div style=text-align:left;margin-left:20px;><img style=\"cursor:pointer;border:0;\" src=\"${contextPath}/templates/${templateName}/images/icon_reload.jpg\" onclick=\"getMore(null,"+topicId+",true);\"  alt=\"[reload]\">&nbsp;<img style=\"cursor:pointer;border:0;\" src=\"${contextPath}/templates/${templateName}/images/icon_more.jpg\" onclick=\"getUrl("+topicId+");\"  alt=\"[more]\"></div>";
};
</script>

<link rel="alternate" type="application/rss+xml" title="RSS" href="${contextPath}/rss/recentTopics${extension}" />

<table cellspacing="0" cellpadding="10" width="100%" align="center" border="0">
	<tr>
		<td class="bodyline" valign="top">
		
			<#assign breadCrumb>
				<table cellspacing="0" cellpadding="2" width="100%" align="center" border="0">
					<tr>
						<td valign="bottom" align="left">
							<a class="nav" href="${JForumContext.encodeURL("/forums/list")}">${I18n.getMessage("ForumListing.forumIndex")}</a>
							&raquo;
							<a id="latest3" class="nav" href="${JForumContext.encodeURL("/recentTopics/list")}">${I18n.getMessage("ForumBase.recentTopics")}</a>
							<#if rssEnabled>
								&nbsp;<a href="${contextPath}/rss/recentTopics${extension}"><img src="${contextPath}/templates/${templateName}/images/xml_button.gif" border="0" align="middle" alt="[XML]" /></a>
							</#if>
						</td>
						<td>&nbsp;
						</td>
					</tr>
				</table>
			</#assign>
			
			${breadCrumb}
			
			<table class="forumline" cellspacing="1" cellpadding="4" width="100%" border="0">
				<tr>
					<th class="thcornerl" nowrap="nowrap" align="center">&nbsp;${I18n.getMessage("Forums.Form.ForumName")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" colspan="2" height="25">&nbsp;${I18n.getMessage("ForumIndex.topics")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.answers")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="100">&nbsp;${I18n.getMessage("ForumIndex.author")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.views")}&nbsp;</th>
					<th class="thcornerr" nowrap="nowrap" align="center">&nbsp;${I18n.getMessage("ForumIndex.lastMessage")}&nbsp;</th>
				</tr>

				<!-- TOPICS LISTING -->
				<#list topics as topic>
				<tr>
					<td class="row2" valign="middle" align="center"><a class="postdetails" href="${JForumContext.encodeURL("/forums/show/${forums.get(topic_index).getId()}")}">${forums.get(topic_index).getName()}</a></td>
					<td class="row1" valign="middle" align="center" width="20"><@presentation.folderImage topic/></td>
					<td class="row1" width="80%">
						<span class="topictitle"><img src="${contextPath}/templates/${templateName}/images/icon_close.gif" border="0" style="margin:0;padding:0;cursor:pointer;" onclick="getMore(this,'${topic.id}')"/>
						<a href="${JForumContext.encodeURL("/posts/list/${topic.id}")}"><#if (topic.title?length == 0)>No Subject<#else>${topic.title?html}</#if></a>
						</span>

						<#if topic.paginate>
							<span class="gensmall">
							<br />
							<@pagination.littlePostPagination topic.id, postsPerPage, topic.totalReplies/>				
							</span>
						</#if>
                        <div class="infoMacro" style="display:none" id="mA_${topic.id}"></div>
					</td>

					<td class="row2" valign="middle" align="center"><span class="postdetails">${topic.totalReplies}</span></td>
					<td class="row3" valign="middle" align="center">
						<span class="name"><a href="${JForumContext.encodeURL("/user/profile/${topic.postedBy.id}")}">${topic.postedBy.username}</a></span>
					</td>

					<td class="row2" valign="middle" align="center"><span class="postdetails">${topic.totalViews}</span></td>
					<td class="row3right" valign="middle" nowrap="nowrap" align="center">
						<#if (topic.lastPostTime?length > 0)>
							<span class="postdetails">${topic.lastPostTime}<br />
							<a href="${JForumContext.encodeURL("/user/profile/${topic.lastPostBy.id}")}">${topic.lastPostBy.username}</a>

							<#assign startPage = ""/>
							<#if (topic.totalReplies + 1 > postsPerPage?number)>
								<#assign startPage = ((topic.totalReplies / postsPerPage?number)?int * postsPerPage?number) +"/"/>
							</#if>
				  
							<a href="${JForumContext.encodeURL("/posts/list/${startPage}${topic.id}")}#${topic.lastPostId}"><img src="${contextPath}/templates/${templateName}/images/icon_latest_reply.gif" border="0" alt="Latest Reply" /></a></span>
						</#if>		 
					</td>
				</tr>
				</#list>		
				<!-- END OF TOPICS LISTING -->
			</table>  
			
			${breadCrumb}
		</td>
	</tr>
</table>
<#include "bottom.htm"/>
